<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Logout Controller
 *
 * @package     VisualQ Local System
 * @author      CSU OJT Students '10 - '11 (Michael Roland B. Martin)
 * @copyright   Copyright (c) 2010 - 2011, Bitstop Network Services, Inc.
 * @version     1.0 January 27, 2011
 */

class Logout extends Controller {

    function Logout()
    {
        parent::Controller();
    }
	
    function index()
    {
        $this->load->helper('date');

        // Check if no user is logged in
        if( ! $this->session->userdata('id'))
        {
            redirect(base_url() . 'login/');
        }

        // Logout DTR
        $dtr = array(
            'account_id'    => $this->session->userdata('id'),
            'action'        => 1,
            'time'          => now()
        );
        $this->db->insert('dtr', $dtr);

        // Unset user session
        $data = array(
            'id'            => '',
            'account_type'  => ''
        );
        $this->session->unset_userdata($data);
        redirect(base_url() . 'login/');
    }

}

/* End of file logout.php */
/* Location: ./system/application/controllers/logout.php */